<?php

class Default_Model_User extends Zend_Db_Table_Abstract
{
    protected $_name = 'user';
    public function getDataByUsername($username){
    	$query = $this->select()
                    ->from($this->_name,array('userId', 'username', 'password', 'status'))
                    ->where('username = ?', $username);
        return $this->fetchRow($query);
    }
    public function getDataById($userId){
    	$query = $this->select()
                        ->from($this->_name, array('userId', 'username', 'status', 'sessionId'))
                        ->where('userId = ?',(int)$userId);
        return $this->fetchRow($query);
    }
    public function updatePass($userId, $password){
        $data['password'] = md5($password);
        return $this->update($data, 'userId=' . (int)$userId );
    }
    public function updateSessionId($userId, $sessionId){
        $data['sessionId'] = $sessionId;
        return $this->update($data, 'userId=' . (int)$userId );
    }
    
}

